package org.jeecg.modules.bobo.common.util;

import org.apache.shiro.crypto.hash.Md5Hash;

import java.security.SecureRandom;

/**
 * @program: jeecg-boot-parent
 * @description: 密码加密
 * @author: 三千霜
 * @create: 2020-08-11 11:38
 */

public class PasswordUtil {
    private static String model = "abcdefghijklmnopqrstuvwxyz1234567890";
    public static String getSalt(){
        StringBuffer salt = new StringBuffer();
        char[] m = model.toCharArray();
        for (int i = 0; i < 6; i++) {
            char c = m[(int) (Math.random() * 36)];
            salt = salt.append(c);
        }
        return salt.toString();
    }
    public static String getPassword(String password, String salt, int i) {
        Md5Hash md5Hash = new Md5Hash(password, salt, i);
        return md5Hash.toString();
    }
    public static String getPassword(String password, String salt) {
        Md5Hash md5Hash = new Md5Hash(password, salt, 3);
        return md5Hash.toString();
    }
}
